package com.taptech.doufu.bean.base;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * author zhangyongcun
 * 16/11/7
 * 服务器数据基类 适用于 嵌套一层list 类型的数据
 */

public class BaseResponseListBean<T> {

    /**
     * status : 0
     * user_msg :
     * fail_code : 0
     * data : {"list":[{"id":"62837","type":0,"object_type":"6","object_id":"204773","data":{"topic_type":18,"novel_type":0,"title":"勿惹表弟","images":[{"imgUrl":"http://imgold2.doufu.la/diaobaoimg/hx/N1/6nIEHrGCmbDWxajhK62OIjk9_JZhQiwjDRixRMPgF10QyCRuDH1RnhRXcNe1.jpg","height":150,"width":300,"des":"","path":"http://imgold2.doufu.la/diaobaoimg/hx/N1/6nIEHrGCmbDWxajhK62OIjk9_JZhQiwjDRixRMPgF10QyCRuDH1RnhRXcNe1.jpg","hash_name":""}],"des":"腹黑表弟攻X二货表哥受\n\n\n我有一个烦人的表弟，总是喜欢缠着我，他明明有很多女生追求，却还要脱我的衣服。\n居然还让我教他这么羞耻的事情。\n可恶！\n摊上这么白痴表弟，我只有勉为其难的教他。\n但是！\n为毛线他这么熟练啊！\n催更群：578869012（备注任意角色名，小可爱来撩）\n\n轻松活泼欢脱文\n多评论，多戳菊花，偶尔扫个文\n人气是更文速度的唯一标准\nヘ(_ _ヘ)","tagType":0,"user":{"userId":1702699,"name":"如初一者","icon":"http://imgold2.doufu.la/diaobaoimg/SZ/9W/enwctuEfH2nl_wGlmcRH8Q-0G7lKglXv5CqNna5qJ-imcN4FbmTy3y4fhe0z.png","type":1,"medal":"http://imgold2.doufu.la/doufu/img/medal/141.png","signature":"来一句个性十足的签名吧"},"comuBrief":{"title":"","commId":0,"type":0},"status":1,"article_num":28,"shareUrl":"http://doufu.la/index.php/shareManage/topic?s=204773","author":"如初一者","read_times":"246885","praise_times":"0","add_time":"1468482329","elite":"0","tags":[{"id":"2178","name":"轻松","pattern":"轻松","match_num":"1","match_freq":"2","pingyin":"","pid":null,"update_time":"1423847018","status":"1","class_id":"13","at_home":"0","default":"0","count":"6215","is_recommend":"0","is_recommend_recommend":"0","flower_num":"0","w_img":null,"icon":null,"following_count":"325"},{"id":"2184","name":"现代","pattern":"现代","match_num":"1","match_freq":"2","pingyin":"","pid":null,"update_time":"1442563305","status":"1","class_id":"12","at_home":"0","default":"0","count":"11096","is_recommend":"1","is_recommend_recommend":"1","flower_num":"0","w_img":null,"icon":null,"following_count":"399"},{"id":"4904","name":"每天日更","pattern":"每天日更","match_num":"1","match_freq":"2","pingyin":"","pid":null,"update_time":"1434365120","status":"1","class_id":"19","at_home":"0","default":"0","count":"3","is_recommend":"0","is_recommend_recommend":"0","flower_num":"0","w_img":null,"icon":null,"following_count":"9"},{"id":"19187","name":"腹黑年下攻","pattern":"腹黑年下攻","match_num":"1","match_freq":"2","pingyin":"","pid":null,"update_time":"1442156937","status":"1","class_id":"19","at_home":"0","default":"0","count":"7","is_recommend":"0","is_recommend_recommend":"0","flower_num":"0","w_img":null,"icon":null,"following_count":"1"},{"id":"67244","name":"1对1宠文","pattern":"1对1宠文","match_num":"1","match_freq":"2","pingyin":"","pid":null,"update_time":"1473773496","status":"1","class_id":"19","at_home":"0","default":"0","count":"3","is_recommend":"0","is_recommend_recommend":"0","flower_num":"0","w_img":null,"icon":null,"following_count":"2"}],"sexuality":"1","is_bl":"1","banner_link":"","finished":"0","flowerCount":"22748","sticked":0,"collect_times":"1791","comment_times":"482","update_time":1482256295,"object_type":5,"id":204773,"grant_type":null,"publish_type":"3","is_original":"1","novel_source":"","sexual_name1":"顾修","sexual_name2":"肖斐然","is_vip":"0"},"msg":"如初一者用5200豆币打赏了《勿惹表弟》"}]}
     * time_begin : 1.4823147189453E9
     * time_cost : 0.029701948165894
     * trace : []
     * ip : 1.225
     */

    private int status;
    private String user_msg;
    private int fail_code;
    private DataBeanX data;
    private double time_begin;
    private double time_cost;
    private String ip;
    private List<?> trace;

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getUser_msg() {
        return user_msg;
    }

    public void setUser_msg(String user_msg) {
        this.user_msg = user_msg;
    }

    public int getFail_code() {
        return fail_code;
    }

    public void setFail_code(int fail_code) {
        this.fail_code = fail_code;
    }

    public DataBeanX getData() {
        return data;
    }

    public void setData(DataBeanX data) {
        this.data = data;
    }

    public double getTime_begin() {
        return time_begin;
    }

    public void setTime_begin(double time_begin) {
        this.time_begin = time_begin;
    }

    public double getTime_cost() {
        return time_cost;
    }

    public void setTime_cost(double time_cost) {
        this.time_cost = time_cost;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public List<?> getTrace() {
        return trace;
    }

    public void setTrace(List<?> trace) {
        this.trace = trace;
    }

    public class DataBeanX<T> {
        private T list;

        public T getList() {
            return list;
        }

        public void setList(T list) {
            this.list = list;
        }

    }

    public static <T> List<T> getListFromJSON(String json) throws Exception{
        Type listType = new TypeToken<ArrayList<T>>(){}.getType();
        List<T> list = new Gson().fromJson(json, listType);
        return list;
    }
}
